package com.yhc.service.serviceimpl;

import com.yhc.entity.User;
import com.yhc.entity.mapper.UserMapper;
import com.yhc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

//业务在此
@Service
public class IUserService implements UserService {
    //按类型注入
    @Autowired
    private UserMapper userMapper;

    //    执行注册,应该优化,不允许注册相同的用户名
    //前端校验用户非法输入等
    @Override
    public void save(User user) {
        userMapper.insert(user);
    }

    //    查询，实现用户登录功能
    @Override
    public boolean findUserBylnameAndlpassword(String lname, String lpassword) {
        if (userMapper.selectUserBylnameAndlpassword(lname, lpassword) != null) {
            return true;
        }
        return false;
    }

}
